//import initialData from '../../initial-data'
import { Timer } from '../../src/timer'
import { useRouter } from 'next/router'
import { useTrainingQuery } from '../../src/gql'

const TimerPage = () => {
  const router = useRouter()
  const { id } = router.query

  const { data, error, loading } = useTrainingQuery({
    variables: { id: typeof id === 'string' ? id : id[0] }
  })

  if (loading) return <p>Loading data...</p>
  if (error) return <p>Error loading data.</p>
  if (data?.training) return <Timer training={data.training} />
}

export default TimerPage
